#include <func.h>
int p0;
int p1;
int p2;
int p3;
void sigFunc(int num)
{
kill(p0,9);
kill(p1,9);
kill(p2,9);
kill(p3,9);


}
struct msgbuf
{
   long mpety;
   char mtext[4096];
};
int main (int argc,char* argv[])
{
   //创建一片共享内存；
   int shmid=shmget(1000,4096,IPC_CREAT|0600);
 ERROR_CHECK(shmid,-1,"shmget");
 int *pid = (int *)shmat(shmid, NULL, 0);
    ERROR_CHECK(pid, (void *)-1, "shmat");
    pid[4] = getpid();
   printf("pid=%d\n",pid[4]);
   
   // while (pid[0] == 0 || pid[1] == 0 || pid[2] == 0 || pid[3] == 0)
   // {
   // }
 p0 = pid[0];
    p1= pid[1];
    p2 = pid[2];
    p3 = pid[3];
    signal(SIGUSR1,sigFunc);
    int msgid = msgget(1000,0);
    
struct msgbuf mbuf;

    while(1)
    {
      msgrcv(msgid,&mbuf,sizeof(mbuf.mtext),1,0);
      printf("A say:%s",mbuf.mtext);

    }
    return 0;
}